package webu

import (
	"github.com/gin-gonic/gin"
	"likeadmin/clog"
	"net/http"
)

// gin的结果
func GinResult(errMsg string, c *gin.Context, err error) {
	if err != nil {
		clog.Info(errMsg, err.Error())
		c.JSON(http.StatusOK, gin.H{
			"code": -1,
			"msg":  err.Error(),
		})
	} else {
		c.JSON(http.StatusOK, gin.H{
			"code": 200,
			"msg":  "success",
		})
	}
}

func GinCountResult(c *gin.Context, count *int) {
	c.JSON(http.StatusOK, gin.H{
		"code": 200,
		"data": map[string]interface{}{
			"count": count,
		},
	})
}
